package com.amigo.online.provider.manager.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.amigo.online.common.base.controller.BaseController;
import com.amigo.online.common.core.response.Response;
import com.amigo.online.provider.manager.model.entity.TipoffTbl;
import com.amigo.online.provider.manager.service.ReportDataService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@RestController
@RequestMapping(value = "/reportData", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public class ReportDataController extends BaseController {

    @Resource
    private ReportDataService reportDataService;


    /**
     * 查询举报
     *
     * @param musicTbl
     * @return
     */
    @PostMapping(value = "/gettipofflist")
    public ResponseEntity<Response> getMusicTbl(@RequestBody TipoffTbl tipoffTbl) {
        JSONObject result = new JSONObject();
        // 分页语句
        Page<Object> page = PageHelper.startPage(tipoffTbl.getPageNo(), 10);
        List<TipoffTbl> tipofflist = reportDataService.select(tipoffTbl);
        result.put("tipofflist", tipofflist);
        result.put("pagetotal", page.getTotal());
        return success(result);
    }

    @PutMapping(value = "/updatetipoff")
    public ResponseEntity<Response> updatetipoff(@RequestBody TipoffTbl tipoffTbl) {
        tipoffTbl.setUpdatedTime(System.currentTimeMillis());
        if (reportDataService.update(tipoffTbl) <= 0) {
            return success(false);
        } else {
            return success(true);
        }


    }


}
